package org.gwtEss.other;

import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Event.NativePreviewEvent;
import com.google.gwt.user.client.Event.NativePreviewHandler;

public abstract class DragTrack{
	HandlerRegistration eventPreviewHandle;
	NativePreviewHandler nativePreviewHandler = new NativePreviewHandler(){

		public void onPreviewNativeEvent(NativePreviewEvent event) {
//			event.cancel();
			event.cancel();
			switch(event.getTypeInt()){
			case Event.ONMOUSEUP:
				eventPreviewHandle.removeHandler();
				onMouseUp(event.getNativeEvent().getClientX());
				break;
			case Event.ONMOUSEMOVE:
				onMouseMove(event.getNativeEvent().getClientX());
				break;
			};
		}
		
	};
	public DragTrack() {
		eventPreviewHandle = Event.addNativePreviewHandler(nativePreviewHandler);
	}
	public abstract void onMouseUp(int mouseX);
	public abstract void onMouseMove(int mouseX);
	
}